<?php
$PanelString = '<h2>'.$Context->GetDefinition('VcalCalendarFilter').'</h2><div id="CalendarFilter"><ul>';
	$CalendarManager = $Context->ObjectFactory->NewContextObject($Context, 'CalendarManager');
	$Calendar = $Context->ObjectFactory->NewObject($Context, 'Calendars');
	$ResultSet = $CalendarManager->GetCalendars(1,0,1);

	$SessionPostBackKey = $Context->Session->GetVariable('SessionPostBackKey', 'string');
	while ($Row = $Context->Database->GetRow($ResultSet)) {
		$Calendar->Clear();
		$Calendar->GetPropertiesFromDataSet($Row);
		$Calendar->FormatPropertiesForDisplay();
		$PanelString .= '<li>
                                    <span id="CalendarID_'.$Calendar->CalendarID.'">
                                        <input type="checkbox" id="CalendarID_'.$Calendar->CalendarID.'" name="CalendarID_'.$Calendar->CalendarID.'" value="'.$Calendar->CalendarID.'"'. (FlipBool($Calendar->Blocked) == 1 ? ' checked="checked"':'').' onClick="ToggleCalendarFilter(\'extensions/Vcal/library/BlockCalendar.php\', '.$Calendar->CalendarID.', '.FlipBool($Calendar->Blocked).', \'CalendarID_'.$Calendar->CalendarID.'\', \''.$SessionPostBackKey.'\', 1);" ></input>
                                        <label style="background-color:'.$Calendar->ColorArr[0].';border:1px solid '.$Calendar->ColorArr[1].';color:'.$Calendar->ColorArr[2].';">'.$Calendar->Title.'</label>    
                                    </span>
                                </li>';
	}
        if ($Context->Session->User->Permission('PERMISSION_VCAL_ADD_CALENDAR'))
            $PanelString .='<a href="'.GetUrl($this->Context->Configuration, "settings.php", '', '', '', '',
"PostBackAction=Calendar&btnSave=Create+a+new+calendar").'" >'.$Context->GetDefinition('VcalAddNewCalendar').'<a>';
            
	$PanelString .= '</ul></div>';

	// Add to controls
	$Panel->AddString($PanelString);
        $Head->AddScript('extensions/Vcal/js/BlockCalendar.js');
        //ToggleCalendarFilter(AjaxUrl, CalendarID, Block, SenderID, PostBackKey, RefreshPage)
?>